package com.wuhunyu.utils;

import org.springframework.beans.factory.InitializingBean;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.context.properties.ConfigurationProperties;
import org.springframework.context.annotation.PropertySource;
import org.springframework.stereotype.Component;

/**
 * 微信常量工具类
 *
 * @author wuhunyu
 * @version 1.0
 * @date 2021-01-23 23:07
 */
@Component
@ConfigurationProperties(prefix = "wechat.open")
@PropertySource("classpath:application.yml")
public class WeChatConstant implements InitializingBean {

    @Value("${app_id}")
    private String appId;

    @Value("${app_secret}")
    private String appSecret;

    @Value("${redirect_url}")
    private String redirectUrl;

    @Value("${back_url}")
    private String backUrl;

    public static String APP_ID;

    public static String APP_SECRET;

    public static String REDIRECT_URL;

    public static String BACK_URL;

    @Override
    public void afterPropertiesSet() throws Exception {
        APP_ID = this.appId;
        APP_SECRET = this.appSecret;
        REDIRECT_URL = this.redirectUrl;
        BACK_URL = this.backUrl;
    }
}
